﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Web;
using SysFile = System.IO.File;
using System.Text;
using System.Collections;
using Yitter.IdGenerator;
using Newtonsoft.Json.Linq;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
using WebService.EF;
using WebService.Authorize;
using WebService.EF.Tables;
using YaseiAkira.AJ.Util;


namespace WebService.Controllers.System
{
    /// <summary>
    /// 称重相关接口
    /// </summary>
    [ApiController]
    [ApiExplorerSettings(GroupName = "system")]
    [Route("system/[controller]/[action]")]
    [AJAuthorize]
    public class WeighController : Controller
    {
        private DbService db;
        private readonly IConfiguration _config;

        public WeighController(DbService dbIns,  IConfiguration config)
        {
            db = dbIns;
            _config = config;
        }

        [HttpPost]
        public Task<int> PushCache(WeighingDataCache data)
        {
            if(data == null)
            {
                Util.FriendlyError("所提交数据有误");
            }

            return data.SaveAsync(db);
        }
    }
}
